<template>
  <el-main>
    <div class="box">
      <div class="box1">
        用户id：<span class="text"> {{ userInfo.userId }}</span>
      </div>
      <div class="box1">
        用户名：<span class="text"> {{ userInfo.userName }}</span>
      </div>
      <div class="box1">
        当前积分：<span class="text">{{ userInfo.points }}</span>
      </div>
    </div>
    <!-- table -->
    <el-table style="overflow: scroll; height: 70vh; width: 100%" :data="tableData"
      :default-sort="{ prop: 'points', order: 'descending' }">
      <el-table-column type="index" width="50"> </el-table-column>
      <el-table-column prop="id" label="Id" sortable width="180">
      </el-table-column>
      <el-table-column prop="userId" label="用户Id" sortable width="180">
      </el-table-column>
      <el-table-column prop="userName" label="用户名"> </el-table-column>
      <el-table-column prop="email" label="邮件"> </el-table-column>
      <el-table-column prop="points" label="积分" sortable width="180">
      </el-table-column>
      <el-table-column prop="updateTime" label="更新时间">
        <template v-slot="{ row }">
          {{ row.updateTime | formatDate }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间">
        <template v-slot="{ row }">
          {{ row.createTime | formatDate }}
        </template>
      </el-table-column>
    </el-table>
  </el-main>
</template>

<script>
import mixin from "@mixins";
import { mapState } from "vuex";
export default {
  mixins: [mixin.admin],
  data() {
    return {
      tableData: [
      ],
      userInfo: {},
    };
  },
  methods: {
    async fetchData() {
      const res1 = await this.$api.getPointByUserId({ userId: "string" });
      const res2 = await this.$api.getOrderByPoints();
      this.userInfo = res1.data;
      this.tableData = res2.data;
    },
  },
  computed: {
    ...mapState({ user: "currentUser" }),
  },
  created() {
    this.fetchData();
  },
};
</script>

<style lang="less" scoped>
.box {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  margin-bottom: 15px;
  border-bottom: 1px solid #DCDFE6;
  padding-bottom: 10px;
}

.box1 {
  display: flex;
  align-items: center;
  justify-content: center;
}

.text {
  color: #409EFF;
}
</style>
